package net.lcheng.service.impl;

import net.lcheng.dao.BaseAreasMapper;
import net.lcheng.model.BaseAreas;
import net.lcheng.model.BaseAreasExample;
import net.lcheng.service.AreasService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by LV on 2016/6/29.
 */
@Service("areasService")
public class AreasServiceImpl implements AreasService {

    @Resource
    private BaseAreasMapper areasMapper;
    /**
     * 根据parentCode查找区域列表
     * @param parentCode
     * @return
     */
    @Override
    public List<BaseAreas> findAreasListByParentCode(String parentCode) {
        BaseAreasExample example=new BaseAreasExample();
            example.createCriteria().andParentCodeEqualTo(parentCode)
                .andStatusEqualTo(1);
        example.setOrderByClause("sibling_sort DESC");

        List<BaseAreas> areas=areasMapper.selectByExample(example);
        if(areas!=null&&areas.size()>0)
            return areas;
        return null;
    }
}
